<template>
<section>
  <el-col :span="24" style="padding-top:10px;padding-bottom:10px;">
            <el-button round type="primary" @click="addInbound"  size="small" icon="el-icon-plus">新增入库</el-button> 
             <el-dropdown trigger="click">
                <el-button round size="small" type="primary" plain class="el-dropdown-link">
                    <i><font-awesome-icon :icon="['far','edit']"/></i>&nbsp;编辑/删除
                </el-button>
                <el-dropdown-menu  slot="dropdown">
                    <el-dropdown-item @click.native="updateInbound">修改</el-dropdown-item>
                    <el-dropdown-item @click.native="delInbound">删除</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
            <el-dropdown trigger="click">
                <el-button round size="small" type="primary" plain class="el-dropdown-link">
                    <i><font-awesome-icon :icon="['fas','sign-out-alt']"/></i>&nbsp;导入/导出
                </el-button>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>导入</el-dropdown-item>
                    <el-dropdown-item>导出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </el-col>
     <el-table
      v-loading="listLoading"
    border
    ref="multipleTable"
    :data="tableData"
    tooltip-effect="dark" 
    style="width: 100%"
    @row-click="rowClick"
    @selection-change="handleSelectionChange">
    <el-table-column
      type="selection">
    </el-table-column>
    <el-table-column
    fixed
      prop="assetName"
      label="名称"
      width="120"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      label="状态" 
      prop="status"
      width="70">
      <template slot-scope="scope">
        <el-tag  
          size="mini"
          :type="scope.row.status == 2 ? 'warning' : 'success'">
          {{scope.row.status==2?"在用":"闲置"}}
        </el-tag>
      </template>
    </el-table-column>
    <el-table-column
      prop="assetNum"
      label="编号"
      width="120">
    </el-table-column>
    <el-table-column
      prop="standardName"
      label="规格"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="unitPrice"
      label="单价"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="belongName"
      label="所属公司"
      width="120"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      width="120"
      prop="userPCompanyName"
      label="使用公司"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="useDepartment"
      label="使用部门"
      width="120"
      show-overflow-tooltip>
      <template slot-scope="scope">
          {{scope.row.userType == 2?scope.row.userName:''}}
      </template>
    </el-table-column>
    <el-table-column
      prop="useMan"
      label="使用人员"
      width="120"
      show-overflow-tooltip>
        <template slot-scope="scope">
          {{scope.row.userType == 3?scope.row.userName:''}}
        </template>
    </el-table-column>
    <el-table-column
      prop="useEndTime"
      label="使用到期日期"
      width="120"
      show-overflow-tooltip>
      <template slot-scope="scope">
          {{scope.row.status == 2?scope.row.useType == 2?scope.row.useEndTime:'长期':''}}
      </template>
    </el-table-column>
    <el-table-column
      prop="assetAdmin"
      label="管理员"
      show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="crateTime"
      label="入库时间"
      width="120"
      show-overflow-tooltip>
    </el-table-column>
  </el-table>
   <el-col :span="24" class="toolbar">
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[20, 50, 100, 200]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalNum">
        </el-pagination>
    </el-col>

    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" @open="dialogOpen" @close="resetForm('addForm')">
            <el-form :model="addForm" size="small" :rules="rules" ref="addForm" label-position="right" label-width="86px">
                <el-row :gutter="10">
                    <el-col :span="8">
                    <el-form-item label="编号">
                        <el-input v-model="addForm.assetNum" placeholder="系统默认分配" :disabled="true"></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="资产名称" prop="assetName"> 
                        <el-input placeholder="请选择资产条目" :disabled="showDetail" v-model="assetInfoItem.assetName">
                            <i slot="append" class="fa-icon-location" @click="selectAssetInfos(true)">
                                <font-awesome-icon :icon="['fa','user']"/>
                            </i>
                        </el-input> 
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="资产类别" prop="classify">  
                        <el-input v-model="assetInfoItem.classifyName"
                            disabled></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="规格/型号" prop="standardName">  
                          <el-input v-model="assetInfoItem.standrad"
                            disabled></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="计量单位" prop="unit">
                        <el-input v-model="assetInfoItem.unit"
                            disabled></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="单价" prop="unitPrice">
                        <el-input v-model="assetInfoItem.unitPrice"
                            disabled></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="品牌" prop="brandName">
                         <el-input v-model="assetInfoItem.brand"
                            disabled></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="供应商" prop="supplier">
                        <el-input :disabled="showDetail"  v-model="addForm.supplier"></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="来源" prop="assetFromType"> 
                         <el-select :disabled="showDetail" v-model="addForm.assetFromType" filterable placeholder="请选择">
                            <el-option
                            v-for="item in assetFrom"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select> 
                    </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="10">
                    <el-col :span="8">
                    <el-form-item label="所属公司"  prop="company">
                        <el-cascader 
                         :disabled="showDetail"  
                            :options="companyList"
                            v-model="addForm.company"
                            change-on-select
                            :props="classifyProps">
                        </el-cascader>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="存储区域" prop="area">
                        <el-select :disabled="showDetail" v-model="addForm.area" filterable placeholder="请选择">
                            <el-option 
                            v-for="item in areaList"
                            :key="item.id"
                            :label="item.areaName"
                            :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="管理员" prop="adminUser">
                        <el-select :disabled="showDetail" v-model="addForm.adminUser" filterable placeholder="请选择">
                            <el-option
                            v-for="item in userList"
                            :key="item.id"
                            :label="item.userName"
                            :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="使用公司" prop="useCompany">
                        <el-cascader  
                         :disabled="showDetail" 
                            :options="companyList"
                            change-on-select
                            @change="handleCompanyChange"
                            v-model="addForm.useCompany" 
                            :props="classifyProps">
                        </el-cascader>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="使用部门" prop="department">
                         <el-cascader  
                          :disabled="showDetail" 
                            :options="groupTemp"
                            v-model="addForm.department" 
                            @change="handleDepartmentChange"
                            :props="classifyProps">
                        </el-cascader>
                    </el-form-item>
                    </el-col>
                    <el-col :span="8">
                    <el-form-item label="使用人员" prop="userName">
                        <el-input :disabled="showDetail" placeholder="请输入内容" v-model="selectItem.userName" @change="searchUserName">
                            <i slot="append" class="fa-icon-location" @click="selectUser(true)">
                                <font-awesome-icon :icon="['fa','user']"/>
                            </i>
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="24"> 
                        <el-row>
                            <el-col :span="10">
                                 <el-form-item label="入库时间" prop="inDate"> 
                                     <el-date-picker
                                      :disabled="showDetail"
                                        v-model="addForm.inDate"
                                        type="date"
                                        @change="inDateChange"
                                        format="yyyy-MM-dd" 
                                        value-format="yyyy-MM-dd"
                                        placeholder="选择日期">
                                        </el-date-picker>
                                 </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                    <el-form-item label="使用期限" prop="endTime"> 
                                        <el-date-picker
                                         :disabled="showDetail"
                                        v-model="addForm.endTime"
                                        type="date"
                                        @change="endDateChange"
                                        format="yyyy-MM-dd" 
                                        value-format="yyyy-MM-dd"
                                        placeholder="使用结束日期"> 
                                        </el-date-picker>
                                    </el-form-item>
                            </el-col>
                            <el-col :span="4">
                                <el-popover
                                placement="top-start"
                                title="提示"
                                width="220"
                                trigger="hover"
                                content="如果使用期限为空，系统将默认为长期使用">
                                <i slot="reference" style="color:#E6A23C;font-size:18px;">
                                    <font-awesome-icon :icon="['fas','info-circle']"/>
                                </i>
                            </el-popover>
                            </el-col>
                       
                        </el-row>
                    </el-col>
                    <el-col>
                         <el-form-item label="备注" prop="note"> 
                            <el-input
                                type="textarea"
                                :rows="2"
                                 :disabled="showDetail"
                                placeholder="请输入备注"
                                v-model="addForm.note">
                                </el-input>
                         </el-form-item>
                    </el-col>
                
                </el-row>
                
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button v-show="!showDetail" key="reset" @click="resetForm('addForm')">重置</el-button>
                <el-button v-show="!showDetail" key="submit" type="primary" :loading="submitLoading" @click="submitForm('addForm')">确 定</el-button>
            </div>
        </el-dialog>  

        <el-dialog title="选择使用员工" :visible.sync="isDialogShow" @close="selectUser(false)">
            <section>
                <EmployeeTable></EmployeeTable>
            </section>
            <div slot="footer" class="dialog-footer">
                <el-button @click="selectUser(false)">取 消</el-button> 
            </div>
        </el-dialog>

        <el-dialog title="选择资产条目" :visible.sync="isAssetInfoDialogShow" @close="selectAssetInfos(false)">
            <section>
                <AssetInfoTable ref="assetInfoTable"></AssetInfoTable>
            </section>
            <div slot="footer" class="dialog-footer">
                <el-button @click="selectAssetInfos(false)">取 消</el-button> 
            </div>
        </el-dialog>
</section>


   
</template>

<script>
import EmployeeTable from "@/views/system/employee/employees/Container";
import AssetInfoTable from "@/views/system/staticassets/assetInfo/Container";
import { formatDate } from "@/common/DateUtil.js";
import api from "@/service/api";
import http from "@/service/http";

import store from "@/store";
import { mapActions, mapGetters } from "vuex";
import { Container } from "element-ui";
//const { mapActions, mapGetters } = createNamespacedHelpers("system/employee");

export default {
  components: { EmployeeTable, AssetInfoTable },
  data() {
    var validateAssetInfo = (rule, value, callback) => {
      if (this.assetInfoItem == null || this.assetInfoItem.id == "") {
        callback(new Error("请选择资产条目"));
      } else {
        callback();
      }
    };
    return {
      user: {},
      value8: [],
      options: [],
      select: [],
      listLoading: false,
      pageSize: 20,
      totalNum: 0,
      currentPage: 1,
      tableData: [],
      classify: [],
      submitType: 1, //表单类型，1：add ,2:update
      dialogFormVisible: false,
      isAssetDialogShow: false,
      employeesDialogVisible: false,
      submitLoading: false,
      dialogTitle: "",
      addForm: {
        assetId: "",
        classify: [],
        assetNum: "",
        assetName: "",
        standardName: "",
        unit: "",
        unitPrice: "",
        brand: "",
        supplier: "",
        from: "",
        brandName: "",
        company: [], //所属公司
        useCompany: [],
        area: "",
        assetFromType: "",
        adminUser: "",
        department: [],
        user: { userId: "", userType: "", userName: "" },
        inDate: new Date(),
        endTime: "",
        note: ""
      },
      rules: {
        assetName: [{ rvalidator: validateAssetInfo, trigger: "blur" }],
        company: [
          { required: true, message: "请选择所属公司", trigger: "change" }
        ],
        area: [
          { required: true, message: "请选择存储区域", trigger: "change" }
        ],
        adminUser: [
          { required: true, message: "请选择管理员", trigger: "change" }
        ]
      },
      classifyProps: {
        label: "name",
        value: "id",
        children: "child",
        disabled: "disabled"
      },
      assetNames: [],
      standardNames: [],
      companyList: [],
      areaList: [],
      userList: [],
      departmentList: [],
      groupTemp: [],
      multipleSelection: [],
      assetFrom: [],
      showDetail: false
    };
  },
  computed: {
    //导入store的getters属性
    ...mapGetters({
      isToSelect: "system/employee/isToSelect",
      isDialogShow: "system/employee/isDialogShow",
      selectItem: "system/employee/selectItem",
      isAssetInfoDialogShow: "system/assetInfo/isDialogShow",
      assetInfoItem: "system/assetInfo/assetInfoItem"
    })
  },
  methods: {
    //导入actions方法
    ...mapActions({
      toSelect: "system/employee/toSelect",
      showDialog: "system/employee/showDialog",
      selectEpmloyeeItem: "system/employee/selectEpmloyeeItem",
      assetToSelect: "system/assetInfo/toSelect",
      selectItemChange: "system/assetInfo/selectItemChange",
      showAssetDialog: "system/assetInfo/showDialog"
    }),
    //单击行
    rowClick(row) {
      this.dialogTitle = '资产详情';
      this.showDetail = true;
      var inbound = row;
      var assetInfo = {
        id: inbound.assetInfoId,
        brand: inbound.brandName,
        assetName: inbound.assetName,
        unit: inbound.unit,
        unitPrice: inbound.unitPrice,
        standrad: inbound.standardName,
        classifyId: inbound.assetClassifyId,
        classifyName: inbound.assetClassifyName
      };
      this.selectItemChange(assetInfo);

      this.addForm.assetId = inbound.assetId;
      this.addForm.classify = inbound.assetClassifyPIds;
      this.addForm.assetName = inbound.assetName;
      this.addForm.standardName = inbound.standardName;
      this.addForm.unit = inbound.unit;
      this.addForm.unitPrice = inbound.unitPrice;
      this.addForm.brandName = inbound.brandName;
      this.addForm.supplier = inbound.supplier;
      this.addForm.assetFromType = inbound.fromType;
      this.addForm.assetNum = inbound.assetNum;
      this.addForm.area = inbound.areaId;
      this.addForm.adminUser = inbound.assetAdminId;
      this.addForm.inDate = formatDate(
        new Date(inbound.inboundTime),
        "yyyy-MM-dd hh:mm:ss"
      );
      this.addForm.endTime = inbound.useType==1?'':formatDate(
        new Date(inbound.useEndTime),
        "yyyy-MM-dd hh:mm:ss"
      );
      this.addForm.company = inbound.parentCompany;
      this.addForm.note = inbound.note;

      if (inbound.userType == 3) {
        //员工
        this.selectEpmloyeeItem({
          userId: inbound.userId,
          userName: inbound.userName,
          userType: inbound.userType
        });
      } else if (inbound.userType == 2) {
        this.addForm.department = inbound.parentPids;
      }
      this.dialogFormVisible = true;
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.staticAssetInbound();
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.addForm = {};
      this.showDetail = false;
      this.$refs[formName].resetFields();
      this.addForm.assetNum = "";
      this.selectEpmloyeeItem({
        userId: "",
        userName: "",
        userType: ""
      });
      this.selectItemChange({});
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getInboundList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
      this.getInboundList();
    },
    //新增入库点击
    addInbound() {
      this.dialogFormVisible = true;
      this.submitType = 1;
      this.dialogTitle = "新增入库";
    },
    //更新
    updateInbound() {
      this.submitType = 2;
      if (this.multipleSelection.length == 0) {
        this.$message({
          message: "请选择记录",
          type: "warning"
        });
        return;
      }
      if (this.multipleSelection.length != 1) {
        this.$message({
          message: "一次只能修改一条记录",
          type: "warning"
        });
        return;
      }
      this.dialogTitle = "修改入库";
      var inbound = this.multipleSelection[0];
      var assetInfo = {
        id: inbound.assetInfoId,
        brand: inbound.brandName,
        assetName: inbound.assetName,
        unit: inbound.unit,
        unitPrice: inbound.unitPrice,
        standrad: inbound.standardName,
        classifyId: inbound.assetClassifyId,
        classifyName: inbound.assetClassifyName
      };
      this.selectItemChange(assetInfo);

      this.addForm.assetId = inbound.assetId;
      this.addForm.classify = inbound.assetClassifyPIds;
      this.addForm.assetName = inbound.assetName;
      this.addForm.standardName = inbound.standardName;
      this.addForm.unit = inbound.unit;
      this.addForm.unitPrice = inbound.unitPrice;
      this.addForm.brandName = inbound.brandName;
      this.addForm.supplier = inbound.supplier;
      this.addForm.assetFromType = inbound.fromType;
      this.addForm.assetNum = inbound.assetNum;
      this.addForm.area = inbound.areaId;
      this.addForm.adminUser = inbound.assetAdminId;
      this.addForm.inDate = formatDate(
        new Date(inbound.inboundTime),
        "yyyy-MM-dd hh:mm:ss"
      );
      this.addForm.endTime = inbound.useType==1?'':formatDate(
        new Date(inbound.useEndTime),
        "yyyy-MM-dd hh:mm:ss"
      );
      this.addForm.company = inbound.parentCompany;
      this.addForm.note = inbound.note;

      if (inbound.userType == 3) {
        //员工
        this.selectEpmloyeeItem({
          userId: inbound.userId,
          userName: inbound.userName,
          userType: inbound.userType
        });
      } else if (inbound.userType == 2) {
        this.addForm.department = inbound.parentPids;
      }
      this.dialogFormVisible = true;
    },
    //删除
    delInbound() {
      if (this.multipleSelection.length == 0) {
        this.$message({
          message: "请选择要删除的记录",
          type: "warning"
        });
        return;
      }
      this.$confirm("确认删除所选记录吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.delInboundById();
        })
        .catch(() => {});
    },
    delInboundById() {
      let inboundIds = [];
      this.multipleSelection.map((v, k) => {
        inboundIds.push(v.id);
      });
      console.log({ ids: inboundIds });
      http.post(api.sysApi.delInboundById, inboundIds).then(data => {
        if(!data.success){
				return;
			}
        this.$message({
          message: "删除记录成功",
          type: "success"
        });
        this.getInboundList();
      });
    },
    inDateChange(val) {
      this.addForm.inDate = val;
      console.log(val);
    },
    endDateChange(val) {
      this.addForm.endTime = val;
      console.log(val);
    },
    //选择使用公司
    handleCompanyChange(val) {
      if (val.length == 0) {
        return;
      }
      var a2 = this.departmentList.filter(function(item) {
        return item.id == val[0];
      });
      if (a2.length != 0) {
        this.groupTemp = a2;
      } else {
        this.groupTemp = this.departmentList;
      }
    },
    //选择部门后的回调
    handleDepartmentChange(val) {
      if (val.length == 0) {
        return;
      }
      this.addForm.useCompany = [val[0]];
    },
    getInboundList() {
      this.listLoading = true;
      var search = { pageNum: this.currentPage, pageSize: this.pageSize };
      http.post(api.sysApi.getInboundList, search).then(data => {
        if(!data.success){
				return;
			}
        this.tableData = data.data;
        this.totalNum = data.totalNum;
        this.listLoading = false;
      });
    },
    //选择资产条目
    selectAssetInfos(isOpen) {
      if(this.showDetail){//详情时不可操作
        return;
      }
      this.showAssetDialog(isOpen);
      this.assetToSelect(isOpen ? 2 : 1);
    },
    //入库
    staticAssetInbound() {
      this.submitLoading = true;
      var param = {
        assetId: this.addForm.assetId,
        operatorId: this.user.id,
        assetClassifyId: this.addForm.classify[
          this.addForm.classify.length - 1
        ],
        assetInfoId: this.assetInfoItem.id,
        supplier: this.addForm.supplier,
        fromTypeId: this.addForm.assetFromType,
        areaId: this.addForm.area,
        groupId: this.addForm.company[this.addForm.company.length - 1],
        note: this.addForm.note,
        adminUser: this.addForm.adminUser,
        userId: "",
        userType: "",
        useType: "",
        useCompany:'',
        inDate: formatDate(
          new Date(this.addForm.inDate),
          "yyyy-MM-dd hh:mm:ss"
        ),
        endDate: formatDate(
          new Date(this.addForm.endTime),
          "yyyy-MM-dd hh:mm:ss"
        )
      };
      if(this.addForm.useCompany.length!=0){
          param.useCompany = this.addForm.useCompany[this.addForm.useCompany.length-1];
      }
      if (this.selectItem.userId == "") {
        if (this.addForm.department.length != 0) {
          let dep = this.addForm.department[this.addForm.department.length - 1];
          param.userId = dep;
          param.userType = 2;
        }
      } else {
        (param.userId = this.selectItem.userId),
          (param.userType = this.selectItem.userType),
          (param.userName = this.selectItem.userName);
      }
      if (param.endDate == "") {
        param.useType = 1;
      } else {
        param.useType = 2;
      }
      if (this.submitType == 1) {
        //add
        http.post(api.sysApi.staticAssetInbound, param).then(data => {
        if(!data.success){
				return;
			}
          this.submitLoading = false;
          this.dialogFormVisible = false;
          this.$message({
            message: "入库成功",
            type: "success"
          });
          this.getInboundList();
        });
      } else {
        //update
        http.post(api.sysApi.staticAssetUpdateInbound, param).then(data => {
        if(!data.success){
				return;
			}
          this.submitLoading = false;
          this.dialogFormVisible = false;
          this.$message({
            message: "修改成功",
            type: "success"
          });
          this.getInboundList();
        });
      }
    },
    //dialog open
    dialogOpen() {
      this.getClassifyList();
      this.getAssetName();
      this.getStandardName();
      this.getCompanyList();
      this.getAreaList();
      this.users();
      this.getDepartmentList();
      this.getAssetFromList();
    },
    //获取来源
    getAssetFromList() {
      http.post(api.sysApi.assetFromList, "").then(data => {
        if(!data.success){
				return;
			}
        this.assetFrom = data.data;
      });
    },
    //获取分类
    getClassifyList() {
      var search = { pageNum: this.currentPage, pageSize: this.pageSize };
      http.post(api.sysApi.classifyList, "").then(data => {
        if(!data.success){
				return;
			}
        this.classify = data.data;
      });
    },
    //获取已存在的资产名称
    getAssetName() {
      var search = { searchKey: "" };
      http.post(api.sysApi.selectAssetNameByKey, search).then(data => {
        this.assetNames = data.data;
      });
    },
    //获取公司
    getCompanyList() {
      http.post(api.sysApi.getCompanyList, "").then(data => {
        this.companyList = data.data;
      });
    },
    //获取组织架构
    getDepartmentList() {
      var search = { pageNum: this.currentPage, pageSize: this.pageSize };
      http.post(api.sysApi.getDepartmentList, "").then(data => {
        this.departmentList = data.data;
        this.groupTemp = data.data;
      });
    },
    //获取区域
    getAreaList() {
      let param = { pageNum: 1, pageSize: 200 };
      http.post(api.sysApi.getAreaList, param).then(data => {
        this.areaList = data.data;
      });
    },
    //获取已存在的规格
    getStandardName() {
      var search = { searchKey: "" };
      http.post(api.sysApi.selectStandByNameKey, search).then(data => {
        this.standardNames = data.data;
      });
    },
    //获取管理员列表
    users() {
      var search = { pageNum: 1, pageSize: 200 };
      http.post(api.sysApi.userList, search).then(data => {
        this.userList = data.data;
      });
    },
    handleNameSelect(val) {
      console.log(val);
      this.addForm.assetName = val.assetName;
    },
    queryNameSearch(queryString, cb) {
      var results = queryString
        ? this.assetNames.filter(this.createFilter(queryString))
        : this.assetNames;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    handleStandardSelect(val) {
      console.log(val);
      this.addForm.standardName = val.standardName;
    },
    queryStandarSearch(queryString, cb) {
      var results = queryString
        ? this.standardNames.filter(this.createFilter2(queryString))
        : this.standardNames;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    queryCompanySearch(queryString, cb) {
      var results = queryString
        ? this.standardNames.filter(this.createFilter2(queryString))
        : this.standardNames;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    //选择使用人员
    selectUser(val) {
      if(this.showDetail){
        return;
      }
      this.showDialog(val);
      this.toSelect(val);
    },
    //搜索是否存在用户
    searchUserName(val) {},
    createFilter(queryString) {
      return name => {
        return name.assetName.indexOf(queryString) > -1;
      };
    },
    createFilter2(queryString) {
      return name => {
        return name.standardName.indexOf(queryString) > -1;
      };
    },
    handleNameClick() {}
  },
  mounted() {
    this.user = JSON.parse(localStorage.getItem("user"));
    this.getInboundList();
  }
};
</script>

<style>
.el-pagination {
  float: right;
}
.el-dropdown-link {
  cursor: pointer;
}
.el-dialog {
  width: 72% !important;
}
.fa-icon-location {
  margin-left: 3px;
  width: 14px;
  height: 14px;
  display: inline-block;
  text-align: center;
  font-size: 14px;
  vertical-align: middle;
}
</style>
